package org.meb.speedway;

import lombok.Getter;
import lombok.NonNull;

@Getter
public class Query<T> {

	@NonNull
	private T entity;
	private SortOrder sortOrder;

	public Query(T entity) {
		this(entity, new SortOrder());
	}

	public Query(T entity, SortOrder sortOrder) {
		if (entity == null) {
			throw new IllegalArgumentException("Entity is null");
		}
		this.entity = entity;
		if (sortOrder == null) {
			throw new IllegalArgumentException("Sort order is null");
		}
		this.sortOrder = sortOrder;
	}

	@SuppressWarnings("unchecked")
	public final Class<T> getEntityClass() {
		return (Class<T>) entity.getClass();
	}
}
